Xpath Functionality ------------------- 1.Locating Elements With unknow Element and Attributes Syntax: ------ //*[@attributeName='value'] 2.Locating Elements with know Element and Attributes Syntax: -------- //tagName[@attributeName='value'] 3.Locating Elements with Known vissible Text (exact Match) Syntax: ------- //tagName[text()='exact value'] 4.Locating Element when part of the visible text is known (partial text) Syntax: -------- //tagName[contains(text(),'partial text')] 5.Locating Elements With multiple Attributes To locate an exact element, we can use multiple attribute for selection. Syntax: -------- //*[attribute1='value1'][attribute2='value2'][attribute3='value3'] 6.Locating elements When starting visible text is know Syntax: ------- //tagName[starts-with(text(),'starting text')] 7.Locating Elements With Dynamic Attribute values Syntacx: ------- //tagName[contains(@attributeName,'part of the value')] Locating elements relative to known element =========================================== 1.Locating a parent element syntax: ------ The parent axes contains the parent of the context node. ///parent::elementName Examples: --------- //*[@id='email']/parent::div 2.Locating a child element The child axes contains the children of the context node Syntax: ------- ///child:: Example: -------- (//div[@class='_6lux']/child::input)[1] 3.Locating ancestors of a known element The ancestor axes contains the ancestors of the known element Syntax: ------ ///ancestor:: Examples: --------- //div[@class='_6lux']/ancestor::div 4.Locating following elements Keyword=following:: Syntax: ------ ///following:: 5.Locating preceding elements keyword:preceding Syntax: ------ ///preceding:: 6.Locating following sibling: keyword = following-sibling:: syntax: ------- ///following-sibling:: //*[@id='txtUsername']/following-sibling::span 7.Locating Preceding sibling keyword =preceding-sibling syntax: ///preceding-sibling:: //span[contains(text(),'username')]/preceding-sibling::input